<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <script>
        function getData(param, callback) {
            var iframes = document.createElement('iframe');
            iframes.src = './data.html?p=' + param;
            iframes.style.display = 'none';

            document.body.appendChild(iframes);
            iframes.onload = function () {
                callback(iframes.contentWindow.name);
            };
        }

        function toObj (str) {
            return new Function('return ['+ str + ']')();
        }
        
        window.onload = function() {
            getData(5, function(res) {
                console.log(toObj(res));
            });
        }
    </script>
</head>
<body>
    
</body>
</html>